< previous page page_439 next page >

Page 439
user has changed the colors on his or her computer to the same color, this change wont be visible. A better method is to fill in these text boxes with the word <Required> in italics. This way, the user will immediately see which values need to be filled in (see Figure 22.1).
8160-0439a.gif
Figure 22.1
The 
Controls collection example.
To accomplish this, you need to place the following code in the Click event of the cmdSave command button shown in Figure 22.1:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdSave_Click()
   If FormCheck() Then
      Call FormSave
   End If
End Sub
The Click event in the cmdSave button calls the FormCheck() procedure to perform the validation on the Employee Information form. If the appropriate fields are not filled in, the FormCheck() function fills them in with <Required>. Heres the code for the FormCheck() function:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Function FormCheck() As Boolean
   Dim boolFlag As Boolean
   Dim ctlAny As Control

   txtEmpID.Tag = ""
   txtFirst.Tag = ""
   txtLast.Tag = ""

   If Trim$(txtEmpID) = "" Then
      txtEmpID.Tag = "ERROR"
   End If
   If Trim$(txtFirst) = "" Then
      txtFirst.Tag = "ERROR"

 
< previous page page_439 next page >

If you like this book, buy it!